package com.sczmgk.frame.http;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

import com.sczmgk.hotline.utils.MyLog;


public class ApplicationUtil {
	private static final String TAG = "ApplicationUtil";
	
	public static String APP_NAME = "PAChat";
	public static String APP_VERSION_NAME = null;
	public static String SYSTEM_VERSION_NAME = null;
	public static String SYSTEM_NAME = "android";
	public static String DEVICE_NAME = null;
	
	public static void init(Context context){
		APP_VERSION_NAME = ApplicationUtil.getAppVersionName(context);
		SYSTEM_VERSION_NAME = ApplicationUtil.getSystemVersionName();
		DEVICE_NAME = ApplicationUtil.getDeviceName();
		MyLog.v(TAG, "    :"+getAppInfo());
	}
	
	public static String getAppInfo(){
		return APP_NAME+APP_VERSION_NAME+"("+SYSTEM_NAME+";"+SYSTEM_VERSION_NAME+";"+DEVICE_NAME+")";
	}
    public static String getAppVersionName(Context context) {
        String versionName = "";
        try {
            PackageInfo pinfo = context.getPackageManager()
                    .getPackageInfo(context.getPackageName(),
                            PackageManager.GET_CONFIGURATIONS);
            versionName = "V"+pinfo.versionName;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionName;
    }
    
    public static String getSystemVersionName(){
    	return ""+android.os.Build.VERSION.RELEASE;
//    	return ""+android.os.Build.VERSION.SDK_INT;
    }
    
    public static String getDeviceName(){
//    	android.os.Build.VERSION.RELEASE
    	return ""+android.os.Build.MODEL;
    }
    
}
